package cn.cdut.yiwenqian.aop.logaspect;

import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
@Component
@Aspect
public class Log4jBizAspect {

	private Logger log;
	
	@Pointcut("execution(* cn.cdut.yiwenqian.biz.impl.*.*(..))")
	public void serverPointCut(){}
	
	
	@Before("serverPointCut()")
	public void beforeServerPointCut(JoinPoint pj){
		log=Logger.getLogger(pj.getTarget().getClass().getName());
		String strLog = "log Begining method: "  
                + pj.getTarget().getClass().getName() + "."  
                + pj.getSignature().getName();  
        log.info(strLog);  
	}
	@After("serverPointCut()")
	public void afterServerPointCut(JoinPoint pj){
		log=Logger.getLogger(pj.getTarget().getClass().getName());
		String strLog = "log ehding method: "  
                + pj.getTarget().getClass().getName() + "."  
                + pj.getSignature().getName();  
        log.info(strLog);
	}
	
	
}
